﻿// See https://aka.ms/new-console-template for more information

//string  和  stringbuilder

using System.Text;
//循环次数
int count = 50000;

DateTime start1 = DateTime.Now;
string str = string.Empty;
for(int i= 0;i<count;i++)
{
    str += "helloworld" + i;
}
DateTime end1 = DateTime.Now;

Console.WriteLine("string:"+start1.ToString() + "_" + end1.ToString());


Console.WriteLine("**********************************************");


DateTime start2 = DateTime.Now;
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < count; i++)
{
    stringBuilder.Append("helloworld" + i);
}
DateTime end2 = DateTime.Now;

Console.WriteLine("stringbuilder:"+start2.ToString() +"_"+end2.ToString());


Console.ReadLine();
